package Exercise;

public class Exercise3 {
    public static void main(String[] args) {
        Point center=new Point(2, 3);
        circle c=new circle(center, 2);
        c.draw();
        System.out.println(c.area());
        Shapemanager m=new Shapemanager();
        m.addshape(new circle(new Point(5, 5), 3));
        m.draw();


    }
    
}
class Shape
{
    private static final String DEFAULT_COLOR="black";
    private String color;
    public Shape()
    {
        this(DEFAULT_COLOR);
    }
    public Shape(String color)
    {
        this.color=color;
    }
    public String getcolor()
    {
        return color;
    }
    public void setColor(String color)
    {
        this.color=color;
    }
    public void draw()
    {
        System.out.println("draw");
    }
}
 class circle extends Shape {
    private Point center;
    private double r;
    public circle(Point center,double r)
    {
        this.center=center;
        this.r=r;
    }
    public double area()
    {
        return Math.PI*r*r;
    }
    @Override
    public void draw()
  {
      System.out.println("draw"+center.toString()+"with r"+r+",using color :"+getcolor());
  }  
}
class Shapemanager {
    private static final int MAX_NUM=100;
    private Shape[] shapes=new Shape[MAX_NUM];
    private int shapeNum=0;
    public void addshape(Shape shape)
    {
        if(shapeNum<MAX_NUM)
        {
            shapes[shapeNum++]=shape;
        }
    }
    public void draw()
    {
        for(int i=0;i<shapeNum;i++)
        {
            shapes[i].draw();
        }
    }

    
}